package com.ruoyi.oss.config.properties;

import com.ruoyi.oss.ienum.OssType;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.Serializable;


@Setter
@Getter
@Component
@ConfigurationProperties(value = "oss")
public class OssProperties {

    /**
     * oss服务商类型
     */
    private OssType ossType;

    /**
     * minio配置参数
     */
    private MinioProperties minio = new MinioProperties();

    /**
     * 阿里云配置信息
     */
    private AliYunProperties aliyun = new AliYunProperties();

    /**
     * 腾讯云配置信息
     */
    private QCloudProperties qCloud = new QCloudProperties();

    @Getter
    @Setter
    @NoArgsConstructor
    public static class AliYunProperties implements Serializable {

        private static final long serialVersionUID = -5314587108671501669L;

        /**
         * 阿里云绑定的域名
         */
        private String endpoint;

        /**
         * Endpoint对应的Region信息
         */
        private String region;

        /**
         * 阿里云路径前缀
         */
        private String prefix;

        /**
         * 阿里云AccessKeyId
         */
        private String accessKeyId;

        /**
         * 阿里云AccessKeySecret
         */
        private String accessKeySecret;

        /**
         * 阿里云BucketName
         */
        private String bucketName;

    }


    /**
     * minio 配置
     */
    @Getter
    @Setter
    @NoArgsConstructor
    public static class MinioProperties implements Serializable {
        private static final long serialVersionUID = 4092885961182725947L;
        /**
         * minio域名
         */
        private String endpoint;

        /**
         * minio ACCESS_KEY
         */
        private String accessKey;

        /**
         * minio SECRET_KEY
         */
        private String secretKey;

        /**
         * minio 存储空间名
         */
        private String bucketName;

        /**
         * 前缀
         */
        private String prefix;
    }

    @Getter
    @Setter
    @NoArgsConstructor
    public static class QCloudProperties implements Serializable {

        private static final long serialVersionUID = 8229924271047311550L;
        /**
         * 地址
         */
        private String url;
        /**
         * id
         */
        private String secretId;
        /**
         * 密钥
         */
        private String secretKey;
        /**
         * oss 桶的appid
         */
        private String appId;
        /**
         * 桶的名称
         */
        private String bucketName;
        /**
         * 所在地区
         */
        private String region;
        /**
         * 临时密钥有效时长
         * 单位：秒
         */
        private Integer durationSeconds = 1800;
        /**
         * 文件路径前缀
         */
        private String prefix;
    }

}
